//
//  LLComposeHttpTool.m
//  Weibo
//
//  Created by 李灵斌 on 15-2-6.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "LLComposeHttpTool.h"

@implementation LLComposeHttpTool

+ (void)postPara:(LLComposeRequestPara *)para success:(void (^)(LLComposeRequestResult *))success failure:(void (^)(NSError *))failure{
    
    NSDictionary *dic = para.keyValues;
    
    [LLHttpTool POST:@"https://api.weibo.com/2/statuses/update.json" parameters:dic success:^(id response) {
        
        LLComposeRequestResult *result = [LLComposeRequestResult objectWithKeyValues:response];
        if (success) {
            success(result);  
        }
        
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


+ (void)postPara:(LLComposeRequestPara *)para body:(void(^)(id<AFMultipartFormData> formdata))body success:(void (^)(LLComposeRequestResult *))success failure:(void (^)(NSError *))failure{
    
    NSDictionary *dic = para.keyValues;
    [LLHttpTool POST:@"https://upload.api.weibo.com/2/statuses/upload.json" parameters:dic bodyBlock:^(id<AFMultipartFormData> formData) {
        if (body) {
            
            body(formData);
        }
    } success:^(id response) {
        LLComposeRequestResult *result = [LLComposeRequestResult objectWithKeyValues:response];
        if (success) {
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


@end
